package com.study.jyg.rxjava2study.activity;

import android.widget.ImageView;

import androidx.core.content.ContextCompat;

import com.paradoxie.autoscrolltextview.VerticalTextview;
import com.study.jyg.rxjava2study.R;
import com.study.jyg.rxjava2study.base.BasicActivity;
import com.study.jyg.rxjava2study.utils.glide.GlideUtils;

import java.util.ArrayList;

/**
 * 上下滚动的textview
 */
public class AutoVerticalTextviewActivity extends BasicActivity {

    private VerticalTextview tv;
    private ImageView iv;


    @Override
    protected int getLayout() {
        return R.layout.activity_auto_vertical_textview;
    }

    @Override
    protected void onStart() {
        super.onStart();
        tv.startAutoScroll();
    }

    @Override
    protected void onStop() {
        super.onStop();
        tv.stopAutoScroll();
    }

    @Override
    protected void initView() {
        tv = findViewById(R.id.tv);
        iv = findViewById(R.id.iv);
        GlideUtils.setBackgroud(iv, "http://xsdo.oss-cn-beijing.aliyuncs.com/fdfb5a029a16cdf885892f9e0a35dce5.jpg");
        ArrayList<String> list = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            list.add(String.format("哈哈%s", i));
        }
        tv.setTextList(list);
        tv.setTextList(list);
        tv.setText(13, 5, ContextCompat.getColor(mContext, R.color.colorText33));//设置属性,具体跟踪源码
        tv.setTextStillTime(3000);//设置停留时长间隔
        tv.setAnimTime(300);//设置进入和退出的时间间隔
        //对单条文字的点击监听
        tv.setOnItemClickListener(new VerticalTextview.OnItemClickListener() {
            @Override
            public void onItemClick(int position) {
                // TO DO
            }
        });
    }
}